"""
添加收款单
"""

from page.base_page import BasePage
from selenium.webdriver.common.by import By

class TjSkdPage(BasePage):
    url = "http://192.168.1.25/crm/index.php?m=finance&a=add&t=receivingorder"

    #定位器
    ysk_locator = (By.NAME, 'receivables')
    xz_ysk_locator = (By.CSS_SELECTOR, '#data > tr:nth-child(1) > td:nth-child(1) > input[type=radio]')
    xz_ysk_qd_locator = (By.CSS_SELECTOR,
                         'body > div:nth-child(8) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1)')
    skje_locator = (By.ID, 'money')
    sksj_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tbody/tr[6]/td[2]/input')
    dxk_wjz_locator = (By.NAME, 'status')
    msnr_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tbody > tr:nth-child(8) > td:nth-child(2) > textarea')
    skd_bc_btn_locator = (By.NAME, 'submit')
    skd_qx_btn_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(3)')
    skd_bcxj_btn_locator = (By.NAME, 'submit')
    #操作方法
    #点击应收款
    def click_ysk(self):
        self.driver.find_element(*self.ysk_locator).click()
    #选择应收款人
    def click_xz_ysk(self):
        self.driver.find_element(*self.xz_ysk_locator).click()
    #确定应收款人
    def click_xz_ysk_qd_btn(self):
        self.driver.find_element(*self.xz_ysk_qd_locator).click()
    #输入应收款金额
    def input_skje(self,skje):
        self.driver.find_element(*self.skje_locator).send_keys(skje)
    #输入收款时间
    def input_sksj(self,sksj):
        self.driver.find_element(*self.sksj_locator).send_keys(sksj)
    #点击未结账状态
    def click_wjz(self):
        self.driver.find_element(*self.dxk_wjz_locator).click()
    #输入描述内容
    def input_msnr(self,msnr):
        self.driver.find_element(*self.msnr_locator).send_keys(msnr)
    #点击保存
    def click_bc_btn(self):
        self.driver.find_element(*self.skd_bc_btn_locator).click()
    #点击取消
    def click_qx_btn(self):
        self.driver.find_element(*self.skd_qx_btn_locator).click()
    # 点击保存并新建

    def click_bcxj_btn(self):
        self.driver.find_element(*self.skd_bcxj_btn_locator).click()